﻿<html lang=en>
	<head>
		<meta charset=utf-8>
		<meta http-equiv=X-UA-Compatible content="IE=edge">
		<meta name=viewport content="width=device-width,initial-scale=1">		
		<title>LuaVM Help</title>		
		<link rel="stylesheet" href="style.css" />
	</head>

	<body>
		<h1>LuaVM Developer's Manual</h1>

		<label>Introduction</label>
		<p>
			LuaVM is a Lua virtual machine developed with C# .Net Framework,
			It not only provides GUI for Lua developing and executing, but also offers a set of classes
			and API's for plugin development which gives the greatest potential, by developing plugins, 
			youe Lua scripts can do anything that C# programs can.
		</p>

		<label>Open Source Projects</label>
		<ul>
			<li><a href="https://github.com/Jakosa/LuaInterface" target="_blank">Jakosa/LuaInterface</a> - A bridge between Lua and C#</li>
			<li>
				<a href="https://github.com/efrederickson/KopiLua-v5.1.5" target="_blank">efrederickson/KopiLua</a> - C# implementation of Lua 5.1, I did some modification to bring flexibility on <b style="color:#ff0000;">print</b> function
			</li>
			<li><a href="https://github.com/KindDragon/ICSharpCode.TextEditor" target="_blank">KindDragon/ISharpCode.textEditor</a> - Syntax highlighting and code folding</li>
		</ul>
		<p></p>

		<label>Knowledge Requirements</label>
		<ul>
			<li><a href="http://www.lua.org/manual/5.1" target="_blank">Lua language</a> skill to develop scripts.</li>
			<li><a href="https://docs.microsoft.com/en-us/dotnet/csharp/" target="_blank">C# language</a> skill to develop LuaVM plugins.</li>
		</ul>
		<p></p>

		<label>Additional functions</label>
		The LuaVM environment contains all variables &amp; functions that an ordinary Lua environment does, plus the following additional ones:
		<ul>
			<li><a href="#include">include</a></li>
			<li><a href="#sleep">sleep</a></li>
			<li><a href="#find">process.find</a></li>
			<li><a href="#kill">process.kill</a></li>
		</ul>
		<p></p>

		<a name="include"></a>
		<label>include</label>
		<table class="api-table">
			<tr>
				<td>Function</td>
				<td><code>include(modname)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td><dfn>modname:</dfn> name of the model to load</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>
					Load a model from a lua script file, path of which is specified by _G.package.path, so if the file isn't in current program folder, you will need to assign it to _G.package.path beforehand. This function is a replacement of original Lua require(), which only supports ANSI files.
					<code>package.path = "D:\\test\\?.lua";</code>
					<code>local m = include("MyMod") <tag>-- load D:\\test\\MyMod.lua</tag></code>
					<code>m.doSomething() <tag>-- use the loaded model</tag></code>
				</td>
			</tr>
		</table>

		<a name="sleep"></a>
		<label>sleep</label>
		<table class="api-table">
			<tr>
				<td>Function</td>
				<td><code>sleep(milliseconds)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td><dfn>milliseconds:</dfn> duration of time to sleep, in milliceconds</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>
					Force the main thread of current Lua environment to sleep for a specified duration.
					<code>sleep(2500) <tag>-- wait  for 2.5 seconds</tag></code>
				</td>
			</tr>
		</table>

		<a name="find"></a>
		<label>process.find</label>
		<table class="api-table">
			<tr>
				<td>Function</td>
				<td>
					<code>process.find() <tag>-- list all processes</tag></code>
					<code>process.find(processId) <tag>-- search by process id</tag></code>
					<code>process.find(processName) <tag>-- search by process name</tag></code>
				</td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>processId:</dfn> int ID of the process <br />
					<dfn>processName:</dfn> name of the processes
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					<code>{ { Id, ProcessName, FileName, Arguments, MainWindowHandle, MainWindowTitle }, ... }</code>
					Returns array of all matching process found, or nil if failed.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Search for all matching process, returns all processes if no argument specified.</td>
			</tr>
		</table>

		<a name="kill"></a>
		<label>process.kill</label>
		<table class="api-table">
			<tr>
				<td>Function</td>
				<td>
					<code>process.kill(processId) <tag>-- kill by process id</tag></code>
					<code>process.kill(processName) <tag>-- kill by process id</tag></code>
				</td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>processId:</dfn> int ID of the process to kill <br />
					<dfn>processName:</dfn> name of the process(es) to kill <br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>Returns count of processes killed, or 0 if none</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Kill a process specified by process ID, or kill all processes with specified name.</td>
			</tr>
		</table>

	</body>
</html>